<%@ include file="/inc/charset.jsp" %>
<%@ page import="java.util.*" %>
<%@ page import="com.synchrobit.synchroflow.api.web.*" %>
<%@ page import="com.synchrobit.synchroflow.api.util.*" %>
<%@ page import="com.synchrobit.synchroflow.api.client.*" %>
<%@ page import="com.synchrobit.synchroflow.enactmentservice.processmonitor.*" %>
<%@ page import="com.synchroflow.common.I18NTools" %>
<%@ page import="com.synchroflow.orgInterface.OrgManager"  %>
<%@ page import="com.synchrobit.synchroflow.organization.orgClass.User" %>
<jsp:useBean id="displayTableBean" scope="session" class="com.synchrobit.synchroflow.api.web.DisplayTableBean" />
<jsp:useBean id="sqlBean" scope="session" class="com.synchrobit.synchroflow.api.web.SQLBean" />
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String funName=(String)session.getAttribute("functionName");
%> 
<html>
<head>
<title><%=I18NTools.getString("com.synchroflow.frame.resource","jpgView_title")%>
</title>
<link rel="stylesheet" type="text/css" href="<%=path%>/css/newPage.css">
<Script language="javascript" SRC="./style/common.js"></Script>

</head>
<body topmargin=0 leftmargin=0 rightmargin=0 bottommargin=0>
			
 			<br>
			
			<table width="95%" align="center" cellpadding="0" cellspacing="0">
		  	<tr>
		    <td>	
		      <font class="pageTitle"><%=I18NTools.getString("com.synchroflow.frame.resource","oaWorkItemHis_state")%></font>
		    </td>
		  	</tr>
		  	<tr height="15">
		    <td background="<%=path%>/images/line01.gif">
		    </td>
		  	</tr>
        	</table>
<%

  String processInsId=request.getParameter("processInsId");
  if(processInsId==null || processInsId.length()<=0) {
    out.println(I18NTools.getString("com.synchroflow.frame.resource","oaWorkItemHis_relogin"));
    return;
  }

  sqlBean.clear();
//  ReadXmlConfig xmlConfig=ReadXmlConfig.getInstance();
//  sqlBean.setRmiConnnection(xmlConfig.getDbrmi());
  String selectSql="select process_ins_name,activity_ins_name,created_time,completed_time,state,participant from t_workitem_his where"+
                   " process_ins_id=" + processInsId +
                   " union " +
                   "select process_ins_name,activity_ins_name,created_time,completed_time,state,participant from t_workitem where"+
                   " process_ins_id=" + processInsId +
                   " order by process_ins_name,created_time";
  sqlBean.setSelectSql(selectSql);
  String[][] result=sqlBean.getSelectResultNotNull();
  if (result==null || result.length==0) {
%>
<div align="center">
<br>
<%=I18NTools.getString("com.synchroflow.frame.resource","oaWorkItemHis_no")%>
</div>
</body>
</html>
<%
  return;
  }

  String[][] dispData=new String[result.length][6];
  for(int i=0;i<result.length;i++){
    dispData[i][0]= result[i][0];
    dispData[i][1]= result[i][1];
    dispData[i][2]= result[i][2];
    dispData[i][3]= result[i][3];
    int state=Integer.parseInt(result[i][4]);
    if (state>=4) {
      dispData[i][4]= I18NTools.getString("com.synchroflow.frame.resource","oaWorkItemHis_done") ;
    }else{
      dispData[i][4]= I18NTools.getString("com.synchroflow.frame.resource","oaWorkItemHis_waiting");
    }

    OrgManager orgManager=new OrgManager();
    User curUser=orgManager.getUser(Integer.parseInt(result[i][5]));
	if (curUser!=null)
		  {
		  	dispData[i][5]=curUser.getUname();
		  }

  }
  String[][] dispHeader={{I18NTools.getString("com.synchroflow.frame.resource","oaWorkItemHis_name"),
  I18NTools.getString("com.synchroflow.frame.resource","oaWorkItemHis_item"),
  I18NTools.getString("com.synchroflow.frame.resource","oaWorkItemHis_start"),
  I18NTools.getString("com.synchroflow.frame.resource","oaWorkItemHis_end"),
  I18NTools.getString("com.synchroflow.frame.resource","oaWorkItemHis_flat"),
  I18NTools.getString("com.synchroflow.frame.resource","oaWorkItemHis_men")},
  {"nowrap align='center' class='tableListHeader'"},{"nowrap align='center' class='tableListContent1'","nowrap align='left' class='tableListContent1'","nowrap align='center' class='tableListContent1'"}};
  String tableStyle="width=\"95%\" align=\"center\" cellspacing=\"1\" class='tableList'";
  String tableButtonStyle="width=\"95%\" align=\"center\" class='standardTable'";
  displayTableBean.setMessageLink(true) ;
  displayTableBean.setSetButton(true);
  displayTableBean.setTurnButton(true);
  displayTableBean.setSetButtonImg(path+"/images/set.gif");
  displayTableBean.setSetButtonImgOn(path+"/images/set.gif");
  displayTableBean.setTrunButtonImg(path+"/images/turn.gif");
  displayTableBean.setTrunButtonImgOn(path+"/images/turn.gif");
  displayTableBean.setMouseColor("#dddddd");
  displayTableBean.setStartImg(path+"/images/01.gif");
  displayTableBean.setPreImg(path+"/images/02.gif");
  displayTableBean.setNextImg(path+"/images/03.gif");
  displayTableBean.setEndImg(path+"/images/04.gif");
  displayTableBean.setTrStyle("#efefef","#efefef");
%>

<div align="center">

  <form name="myForm" method="post" action="OaProcessWorkItem.jsp">
  <%

    out.println(displayTableBean.displayTable(request,dispData,dispHeader,10,
      tableStyle,tableButtonStyle,"OaViewWorkItemHis.jsp","&"+request.getQueryString(),"myForm"));
  %>

  </form>
</div>
</body>
</html>
